//
//  ActivityListCell.m
//  UI16.真.豆瓣
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 Amydom. All rights reserved.
//

#import "ActivityListCell.h"
#import "AppTools.h"
#import "UIImageView+WebCache.h"
#define FULLFRAME [[UIScreen mainScreen]bounds]
@implementation ActivityListCell
-(void)dealloc{
    [_posterImage release];
    [_joinDataLabel release];
    [_joinLabel release];
    [_interestDataLabel release];
    [_interestLabel release];
    [_moldLabel release];
    [_addressImage release];
    [_moldDataLabel release];
    [_timeImage release];
    [_titleLabel release];
    [_actImage1 release];
    [_actImage2 release];
    [super dealloc];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatSubView];
        
    }
    return  self;
    
    
}


- (void)creatSubView{
    
    
    self.actImage1 = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 365, 176)];
    self.actImage1.backgroundColor = [UIColor whiteColor];
    self.actImage1.image = [UIImage imageNamed:@"bg_eventlistcell@2x.png"];
    self.actImage1.userInteractionEnabled = YES;
    [self.contentView addSubview:self.actImage1];
    [_actImage1 release];
    
    self.actImage2 = [[UIImageView alloc]initWithFrame:CGRectMake(7, 35, 350, 135)];
    self.actImage2.backgroundColor = [UIColor whiteColor];
    self.actImage2.image = [UIImage imageNamed:@"bg_share_large@2x.png"];
    [self.actImage1 addSubview:self.actImage2];
    [_actImage2 release];
    
    self.timeImage = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 25, 25)];
    self.timeImage.image = [UIImage imageNamed:@"icon_date@2x.png"];
    [self.actImage2 addSubview:self.timeImage];
    [_timeImage release];
    
    self.addressImage = [[UIImageView alloc]initWithFrame:CGRectMake(5, 35, 25, 25)];
    self.addressImage.image = [UIImage imageNamed:@"icon_spot@2x.png"];
    [self.actImage2 addSubview:self.addressImage];
    [_addressImage release];
    
    self.moldImage = [[UIImageView alloc]initWithFrame:CGRectMake(5, 65, 25, 25)];
    self.moldImage.image = [UIImage imageNamed:@"icon_catalog@2x.png"];
    [self.actImage2 addSubview:self.moldImage];
    [_moldImage release];
    
    self.posterImage = [[UIImageView alloc]initWithFrame:CGRectMake(260, 5, 85, 125)];
    self.posterImage.backgroundColor = [UIColor whiteColor];
    [self.actImage2 addSubview:self.posterImage];
    [_posterImage release];
    
    
    
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 345, 20)];
    //    self.titleLabel.backgroundColor = [UIColor whiteColor];
    [self.actImage1 addSubview:self.titleLabel];
    [_titleLabel release];
    
    
    
    self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(32, 7, 220, 20)];
    //    self.timeLabel.backgroundColor = [UIColor blackColor];
    
    [self.actImage2 addSubview:self.timeLabel];
    [_timeLabel release];
    
    self.addressLabel = [[UILabel alloc]initWithFrame:CGRectMake(32, 36, 220, 20)];
    //    self.addressLabel.backgroundColor = [UIColor blackColor];
    [self.actImage2 addSubview:self.addressLabel];
    [_addressLabel release];
    
    
    self.moldLabel = [[UILabel alloc]initWithFrame:CGRectMake(32, 67, 220, 20)];
    self.moldLabel.text = @"类型:";
    
    //    self.moldLabel.backgroundColor = [UIColor blackColor];
    [self.actImage2 addSubview:self.moldLabel];
    [_moldLabel release];
    
    self.moldDataLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 67, 150, 20)];
    [self.actImage2 addSubview:self.moldDataLabel];
    [_moldDataLabel release];
    
    
    self.interestLabel = [[UILabel alloc]initWithFrame:CGRectMake(12, 110, 50, 20)];
    //    self.interestLabel.backgroundColor = [UIColor blackColor];
    self.interestLabel.text = @"感兴趣:";
    self.interestLabel.font = [UIFont systemFontOfSize:13];
    [self.actImage2 addSubview:self.interestLabel];
    [_interestLabel release];
    
    self.interestDataLabel = [[UILabel alloc]initWithFrame:CGRectMake(65, 110, 50, 20)];
    //    self.interestDataLabel.backgroundColor = [UIColor blackColor];
    self.interestDataLabel.font = [UIFont systemFontOfSize:13];
    [self.actImage2 addSubview:self.interestDataLabel];
    [_interestDataLabel release];
    
    
    self.joinLabel = [[UILabel alloc]initWithFrame:CGRectMake(150, 110, 50, 20)];
    //    self.joinLabel.backgroundColor = [UIColor blackColor];
    self.joinLabel.text = @"参加:";
    self.joinLabel.font = [UIFont systemFontOfSize:13];
    [self.actImage2 addSubview:self.joinLabel];
    [_joinLabel release];
    
    self.joinDataLabel = [[UILabel alloc]initWithFrame:CGRectMake(190, 110, 50, 20)];
    //    self.joinDataLabel.backgroundColor = [UIColor blackColor];
    self.joinDataLabel.font = [UIFont systemFontOfSize:13];
    [self.actImage2 addSubview:self.joinDataLabel];
    [_joinDataLabel release];
    
    
    
    
    //    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 5, 200, 40)];
    //    self.nameLabel.text = @"战神";
    //    [self.contentView addSubview:self.nameLabel];
    //    [_nameLabel release];
    //
    //    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 10, 80 , 80*(FULLFRAME.size.height/FULLFRAME.size.width))];
    //    self.headImageView.backgroundColor = [UIColor redColor];
    //    //裁掉view的边界
    //    self.headImageView.layer.masksToBounds = YES;
    //    self.headImageView.layer.cornerRadius = 40;
    //    //设置边框宽度
    //    self.headImageView.layer.borderWidth = 3;
    //    //设置边框颜色
    //    self.headImageView.layer.borderColor = [UIColor orangeColor].CGColor;
    //
    //    [self.contentView addSubview:self.headImageView];
    //    [_headImageView release];
    
    
}



- (void)setMyMovie:(Movie *)myMovie{
    
    if (_myMovie != myMovie) {
        [_myMovie release];
        _myMovie = [myMovie retain];
        
    }
    self.titleLabel.text = self.myMovie.title;
    self.addressLabel.text = self.myMovie.address;
    self.moldDataLabel.text = self.myMovie.category;
    self.interestDataLabel.text = [NSString stringWithFormat:@"%@",self.myMovie.wisher_count];
    self.joinDataLabel.text = [NSString stringWithFormat:@"%@",self.myMovie.participant_count];
    
    NSString *str = [self.myMovie.begin_time substringWithRange:NSMakeRange(5, 11)];
    NSString *str1 = [self.myMovie.end_time substringWithRange:NSMakeRange(5, 11)];
    self.timeLabel.text = [NSString stringWithFormat:@"%@--%@",str,str1];
  /*
     [AppTools getImageWithURL:self.myMovie.pic_url Block:^(NSData *data) {
     //从子线程回到主线程
     dispatch_async(dispatch_get_main_queue(), ^{
     //是否为主线程
     NSLog(@"===%d",[NSThread isMainThread]);
     self.posterImage.image = [UIImage imageWithData:data];
     
     });
     
     
     }];
     
     */
    
    NSURL *url = [NSURL URLWithString:self.myMovie.image];
    [self.posterImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"e8db9451737015bf9622f88a14cc9a40.jpg"]];
    
 
    
}








- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
